package com.ruitu.mall_98_2.mvp.presenter;

import com.beanu.arad.utils.Logg;
import com.beanu.arad.utils.ToastUtils;
import com.ruitu.mall_98_2.mvp.contract.BandingThirdAccountContract;
import com.ruitu.router_module.bean.api.BaseResult;
import com.ruitu.router_module.bean.api.SubscriberImpl;

public class BandingThirdAccountPresenter extends BandingThirdAccountContract.Presenter {
    @Override
    public void bindingQqOrWx(String openId, String type, String accountId,String otherName) {
        mModel.bindingQqOrWx(openId, type, accountId,otherName)
                .subscribe(new SubscriberImpl<BaseResult>() {
                    @Override
                    public void onError(Throwable e) {
                        mView.hideProgress();
                        ToastUtils.showShort("绑定异常");
                        Logg.i(e.toString());
                    }

                    @Override
                    public void onNext(BaseResult baseResult) {
                        mView.hideProgress();
                        if (baseResult.isSuccess()) {
                            mView.setBindingSuc();
                        } else {
                            ToastUtils.showShort(baseResult.getMsg());
                        }
                    }
                });
    }

    @Override
    public void unbindQqOrWx(String type, String accountId) {
        mModel.unbindQqOrWx(type, accountId)
                .subscribe(new SubscriberImpl<BaseResult>() {
                    @Override
                    public void onError(Throwable e) {
                        mView.hideProgress();
                        ToastUtils.showShort("解除异常");
                    }

                    @Override
                    public void onNext(BaseResult baseResult) {
                        mView.hideProgress();
                        if (baseResult.isSuccess()) {
                            mView.setUnbundingSuc();
                        } else {
                            ToastUtils.showShort(baseResult.getMsg());
                        }
                    }
                });
    }

//    @Override
//    public void bindAlipay(String accountId, String alipayId, String alipayName) {
//        mModel.bindAlipay(accountId, alipayId, alipayName)
//                .subscribe(new SubscriberImpl<BaseResult>() {
//                    @Override
//                    public void onError(Throwable e) {
//                        mView.hideProgress();
//                        ToastUtils.showShort("绑定异常");
//                    }
//
//                    @Override
//                    public void onNext(BaseResult baseResult) {
//                        mView.hideProgress();
//                        if (baseResult.isSuccess()) {
//                            mView.setAlipayBindingSuc();
//                        } else {
//                            ToastUtils.showShort(baseResult.getMsg());
//                        }
//                    }
//                });
//    }
}
